﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <meta charset="utf-8" />
</head>
<body>
    <audio id="myAudio"></audio>
    <script>
        var myAudio = document.getElementById('myAudio');
        myAudio.preload = true;
        myAudio.autoplay = true;
        myAudio.src = '../content/audio/海阔天空.mp3';
        myAudio.onplay = function () {
            console.info("开始播放");
        }
        myAudio.oncanplay = function () {
            console.info('进入可以播放状态');
            console.info('总长度：' + myAudio.duration);
        }
        //加载状态监听
        myAudio.ontimeupdate = function (e) {
            /*
            * Audio的缓存只有一个分段，开始位置为0，结束位置为timeRange.end(0)
            */
            //console.info(myAudio.buffered);
            //console.info(myAudio.buffered.length);
            // console.info('start:'+myAudio.buffered.start(0)+',end:'+myAudio.buffered.end(0));
            var timeRange = myAudio.buffered;
            console.info(timeRange);
            console.info('start:' + timeRange.start(0) + ',end:' + timeRange.end(0));
        }
    </script>
</body>
</html>
